import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtCharts

Item {
    id: sbotFocPluginItem
    anchors.fill: parent

    function getGrayscaleColor(value) {
        var base = Math.max(0, Math.min(255, Math.round(value * 255)));
        return `#${base.toString(16).padStart(2, '0').repeat(3)}`;
    }

    function animateHeightChange(targetLayout, target, duration) {
        var componentStr = 'import QtQuick 2.0; PropertyAnimation {}';
        var anim = Qt.createQmlObject(componentStr, sbotFocPluginItem);

        if (anim === null) {
            return;
        }

        anim.target = targetLayout;
        anim.property = "preferredHeight";
        anim.to = target;
        anim.duration = duration;
        anim.easing.type = Easing.InOutQuad;

        anim.runningChanged.connect(function() {
            if (!anim.running) {
                anim.destroy();
            }
        });

        anim.start();
    }

    SplitView {
        anchors.fill: parent

        Rectangle {
            color: "transparent"
            SplitView.preferredWidth: sbotFocPluginItem.width * 0.4

            Rectangle {
                id: focConfig
                anchors.fill: parent
                anchors.margins: 10
                color: "transparent"
                radius: 10

                ColumnLayout {
                    anchors.fill: parent
                    spacing: 5

                    Rectangle {
                        id: devSelect
                        radius: 5
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        color: getGrayscaleColor(0.7)

                        ColumnLayout {
                            width: parent.width
                            spacing: 5

                            Rectangle {
                                Layout.fillWidth: true
                                Layout.preferredHeight: 40
                                color: "transparent"

                                Text {
                                    text: "设备:"
                                    anchors.margins: 10
                                    anchors.left: parent.left
                                    anchors.verticalCenter: parent.verticalCenter
                                }

                                Text {
                                    id: selectDecName
                                    text: "未选择"
                                    anchors.margins: 10
                                    anchors.verticalCenter: parent.verticalCenter
                                    anchors.horizontalCenter: parent.horizontalCenter
                                }

                                MouseArea {
                                    anchors.fill: parent
                                    onClicked: {
                                        if(devSelect.Layout.preferredHeight === 40){
                                            sbotFocPluginItem.animateHeightChange(devSelect.Layout, devSelect.Layout.preferredHeight + 80, 300);
                                        }
                                        else{
                                            sbotFocPluginItem.animateHeightChange(devSelect.Layout, devSelect.Layout.preferredHeight - 80, 300);
                                        }
                                    }
                                }

                                IconImage{
                                    property string iconColor: "gray"

                                    width: 30
                                    height: 30
                                    anchors.margins: 10
                                    anchors.right: parent.right
                                    anchors.verticalCenter: parent.verticalCenter
                                    source: "qrc:/Res/Icon/refresh.png"
                                    color: iconColor

                                    MouseArea{
                                        anchors.fill: parent

                                        onClicked: {
                                            sbotFocPlugin.refreshDev()
                                        }

                                        onEntered:
                                        {
                                            parent.iconColor = "blue"
                                        }

                                        onExited:
                                        {
                                            parent.iconColor = "gray"
                                        }
                                    }
                                }
                            }

                            ListView {
                                Layout.fillWidth: true
                                Layout.preferredHeight: 70
                                spacing: 5
                                model: portList

                                delegate: Rectangle {
                                    width: parent.width
                                    height: 20
                                    color: selected ? "#A9A4A4" : "transparent"
                                    radius: 5

                                    property bool selected: model.selected

                                    Text {
                                        text: model.name
                                        anchors.leftMargin: 10
                                        anchors.left: parent.left
                                        anchors.verticalCenter: parent.verticalCenter
                                    }

                                    IconImage {
                                        width: 15
                                        height: 15
                                        anchors.rightMargin: 10
                                        anchors.right: parent.right
                                        anchors.verticalCenter: parent.verticalCenter
                                        source: "qrc:/Res/Icon/point.png"
                                        color: selected ? "green" : "gray"
                                    }

                                    MouseArea {
                                        anchors.fill: parent
                                        onClicked: {
                                            for (var i = 0; i < portList.count; i++) {
                                                portList.setProperty(i, "selected", false);
                                            }
                                            model.selected = true;
                                            selectDecName.text = model.name
                                            sbotFocPlugin.openDev(model.name)
                                        }
                                    }
                                }
                            }

                            ListModel {
                                id: portList
                                objectName: "sbotFocPortList"

                                function addElement(element) {
                                    append(element);
                                }

                                function clearElement() {
                                    clear();
                                }

                                // ListElement { name: "设备0"; selected: false }
                            }
                        }
                    }

                    Rectangle {
                        id: devInfo
                        radius: 5
                        Layout.fillWidth: true
                        Layout.preferredHeight: 160
                        color: getGrayscaleColor(0.7)

                        ColumnLayout{
                            anchors.fill: parent
                            spacing: 0

                            Rectangle{
                                Layout.fillWidth: true
                                Layout.preferredHeight: 40
                                color: "transparent"

                                Text {
                                    text: "状态:"
                                    anchors.margins: 10
                                    anchors.left: parent.left
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                            }

                            Rectangle{
                                id: phaseData
                                Layout.fillWidth: true
                                Layout.preferredHeight: 40
                                color: "transparent"

                                property string aPhaseData: "0"
                                property string bPhaseData: "0"
                                property string cPhaseData: "0"

                                RowLayout{
                                    anchors.fill: parent
                                    spacing: 0

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "green"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        aPhaseLine.visible = (aPhaseLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "Ua:" + phaseData.aPhaseData + 'v'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "green"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        bPhaseLine.visible = (bPhaseLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "Ub:" + phaseData.bPhaseData + 'v'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "green"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        cPhaseLine.visible = (cPhaseLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "Uc:" + phaseData.cPhaseData + 'v'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }
                                }
                            }

                            Rectangle{
                                id: angleData
                                Layout.fillWidth: true
                                Layout.preferredHeight: 40
                                color: "transparent"

                                property string rtAngleData: "0"
                                property string tarAngleData: "0"

                                RowLayout{
                                    anchors.fill: parent
                                    spacing: 0

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "gray"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        angleLine.visible = (angleLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "RtAngle:" + angleData.rtAngleData + '°'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "gray"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        alphaLine.visible = (alphaLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "TarAlpha:" + angleData.tarAngleData + '°'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }
                                }
                            }

                            Rectangle{
                                id: abData
                                Layout.fillWidth: true
                                Layout.preferredHeight: 40
                                color: "transparent"

                                property string alphaData: "0"
                                property string betaData: "0"

                                RowLayout{
                                    anchors.fill: parent
                                    spacing: 0

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "gray"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        alphaLine.visible = (alphaLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "Alpha:" + abData.alphaData + 'v'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }

                                    Rectangle{
                                        Layout.preferredWidth: parent.width / 3
                                        Layout.fillHeight: true
                                        color: "transparent"

                                        Row{
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            anchors.verticalCenter: parent.verticalCenter

                                            IconImage{
                                                width: 15
                                                height: 15
                                                anchors.right: parent.right
                                                anchors.rightMargin: 15
                                                anchors.verticalCenter: parent.verticalCenter
                                                source: "qrc:/Res/Icon/point.png"
                                                color: iconColor

                                                property string iconColor: "gray"

                                                MouseArea{
                                                    anchors.fill: parent

                                                    onClicked: {
                                                        parent.iconColor = (parent.iconColor === "gray") ? "green" : "gray"
                                                        betaLine.visible = (betaLine.visible) ? false : true
                                                    }
                                                }
                                            }

                                            Text {
                                                text: "Beta:" + abData.betaData + 'v'
                                                width: 20
                                                anchors.verticalCenter: parent.verticalCenter
                                                anchors.horizontalCenter: parent.horizontalCenter
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    Rectangle {
                        id: clearData
                        radius: 5
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        color: getGrayscaleColor(0.7)

                        Text{
                            text: "重置"
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.verticalCenter: parent.verticalCenter
                        }

                        MouseArea{
                            anchors.fill: parent
                            hoverEnabled: true

                            onEntered:
                            {
                                parent.color = getGrayscaleColor(0.5)
                            }

                            onExited:
                            {
                                parent.color = getGrayscaleColor(0.7)
                            }

                            onClicked: {
                                // parent.color = getGrayscaleColor(0.7)

                                rtAngleLine.clear();
                                angleData.rtAngleData = "0";
                                tarAngleLine.clear();
                                angleData.tarAngleData = "0";
                                alphaLine.clear();
                                abData.alphaData = "0";
                                betaLine.clear();
                                abData.betaData = "0";
                                aPhaseLine.clear();
                                phaseData.aPhaseData = "0";
                                bPhaseLine.clear();
                                phaseData.bPhaseData = "0";
                                cPhaseLine.clear();
                                phaseData.cPhaseData = "0";
                                focCharts.xAxisMaxValue = "0";
                            }
                        }
                    }

                    Rectangle {
                        id: stopData
                        radius: 5
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        color: isGreen ? "green" : getGrayscaleColor(0.7)

                        property bool isStop: false
                        property bool isGreen: false
                        property string text: "暂停"

                        Text{
                            text: parent.text
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.verticalCenter: parent.verticalCenter
                        }

                        MouseArea{
                            anchors.fill: parent
                            onClicked: {
                                parent.isGreen = !parent.isGreen
                                parent.text = (parent.text === "暂停") ? "继续" : "暂停"
                                parent.isStop = (parent.isStop) ? false : true
                            }
                        }

                        Behavior on color {
                            ColorAnimation {
                                duration: 500
                            }
                        }
                    }

                    Rectangle {
                        id: devTerminal
                        radius: 5
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        color: getGrayscaleColor(0.4)
                        anchors.margins: 20

                        Rectangle{
                            width: parent.width - 10
                            height: parent.height - 10
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.verticalCenter: parent.verticalCenter
                            color: "transparent"

                            ColumnLayout{
                                anchors.fill: parent
                                spacing: 5

                                Rectangle{
                                    Layout.fillWidth: true
                                    Layout.fillHeight: true
                                    color: "transparent"
                                    radius: 5

                                    ScrollView {
                                        anchors.fill: parent

                                        TextEdit {
                                            anchors.fill: parent
                                            font.family: "Monospace"
                                            font.pointSize: 10
                                            readOnly: true
                                            wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
                                        }
                                    }

                                    Text {
                                        text: "SbotFOC"
                                        font.pixelSize: 30
                                        color: getGrayscaleColor(0.9)
                                        opacity: 0.3
                                        anchors.verticalCenter: parent.verticalCenter
                                        anchors.horizontalCenter: parent.horizontalCenter
                                    }
                                }

                                Rectangle{
                                    Layout.fillWidth: true
                                    Layout.preferredHeight: (devTerminal.height < 110) ? 0 : 40
                                    radius: 5
                                    clip: true
                                    color: getGrayscaleColor(0.7)

                                    ListModel {
                                        id: cmdLists

                                        ListElement { cmd: "reboot"; describe: "重启系统" }
                                        ListElement { cmd: "sfenable"; describe: "使能控制器" }
                                        ListElement { cmd: "sfdisable"; describe: "失能控制器" }
                                        ListElement { cmd: "sfledon"; describe: "打开指示灯" }
                                        ListElement { cmd: "sfledoff"; describe: "关闭指示灯" }
                                        ListElement { cmd: "sf_ols_start"; describe: "启动开环速度模式" }
                                        ListElement { cmd: "sf_ols_stop"; describe: "停止开环速度模式" }
                                        ListElement { cmd: "sfspeed 5"; describe: "sfspeed <speed>   - 设置速度(转/秒)" }
                                    }

                                    ListView {
                                        // anchors.fill: parent
                                        anchors.top: parent.top
                                        anchors.topMargin: 5
                                        anchors.bottom: parent.bottom
                                        anchors.bottomMargin: 5
                                        anchors.right: parent.right
                                        anchors.rightMargin: 5
                                        anchors.left: parent.left
                                        anchors.leftMargin: 5
                                        clip: true
                                        model: cmdLists
                                        spacing: 5

                                        delegate: Rectangle {
                                            width: parent.width
                                            height: 20
                                            color: getGrayscaleColor(0.8)
                                            radius: 5

                                            Row{
                                                anchors.fill: parent
                                                anchors.verticalCenter: parent.verticalCenter

                                                Text {
                                                    text: model.cmd + " : " + model.describe
                                                    anchors.leftMargin: 10
                                                    anchors.verticalCenter: parent.verticalCenter
                                                }
                                            }

                                            MouseArea{
                                                anchors.fill: parent

                                                onClicked: {
                                                    terminalTextField.text = model.cmd
                                                }
                                            }
                                        }
                                    }

                                    MouseArea{
                                        anchors.fill: parent
                                        hoverEnabled: true
                                        propagateComposedEvents: true

                                        onEntered:
                                        {
                                            if(devTerminal.height > 300)
                                            {
                                                sbotFocPluginItem.animateHeightChange(parent.Layout, 120, 300);
                                            }
                                        }

                                        onExited:
                                        {
                                            if(devTerminal.height > 200)
                                            {
                                                sbotFocPluginItem.animateHeightChange(parent.Layout, 40, 300);
                                            }
                                        }
                                    }
                                }

                                Rectangle{
                                    Layout.fillWidth: true
                                    Layout.preferredHeight: 30
                                    color: "transparent"

                                    RowLayout{
                                        anchors.fill: parent
                                        spacing: 5

                                        IconImage{
                                            Layout.fillHeight: true
                                            Layout.preferredWidth: 35
                                            color: getGrayscaleColor(0.7)
                                            source: "qrc:/Res/Icon/Terminal.png"
                                        }

                                        Rectangle{
                                            Layout.fillWidth: true
                                            Layout.fillHeight: true
                                            color: getGrayscaleColor(0.7)
                                            radius: 5

                                            TextField {
                                                id: terminalTextField
                                                anchors.fill: parent
                                                placeholderText: "Terminal:"
                                                font.pixelSize: 15
                                                verticalAlignment: Qt.AlignVCenter
                                                padding: 10

                                                background:{
                                                    color: "transparent"
                                                }

                                                onAccepted: {
                                                    sbotFocPlugin.terminalInput(text)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        handle: Rectangle {
            implicitWidth: 3
            color: "transparent"
            radius: 5

            MouseArea {
                anchors.fill: parent
                hoverEnabled: true

                onEntered:
                {
                    parent.color = "darkgray"
                }

                onExited:
                {
                    parent.color = "transparent"
                }
            }
        }

        ChartView {
            id: focCharts
            title: "SBOT FOC"
            titleColor: getGrayscaleColor(0.5)
            SplitView.preferredWidth: sbotFocPluginItem.width * 0.6
            backgroundColor: sbotFocPluginItem.parent.color
            antialiasing: true
            animationOptions: ChartView.NoAnimation
            legend.labelColor: getGrayscaleColor(0.5)

            property real maxVoltage: 12.6
            property real minVoltage: 0
            property real tickStep: 10 //毫秒
            property real xAxisMaxValue: 0
            property int tickCount: 6
            property int maxPoints: 100 //最大点数

            function appendData(series, x, y) {
                series.append(x, y);
                if (series.count > focCharts.maxPoints) {
                    series.removePoints(0, series.count - focCharts.maxPoints);
                }
            }

            SplineSeries {
                id: rtAngleLine
                name: "rtAngleLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: false
            }

            SplineSeries {
                id: tarAngleLine
                name: "tarAngleLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: false
            }

            SplineSeries {
                id: alphaLine
                name: "alphaLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: false
            }

            SplineSeries {
                id: betaLine
                name: "betaLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: false
            }

            SplineSeries {
                id: aPhaseLine
                name: "aPhaseLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: true
            }

            SplineSeries {
                id: bPhaseLine
                name: "bPhaseLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: true
            }

            SplineSeries {
                id: cPhaseLine
                name: "cPhaseLine"
                axisX: xAxis
                axisY: yAxis
                useOpenGL: true
                visible: true
            }

            ValuesAxis {
                id: xAxis
                min: focCharts.xAxisMaxValue - (focCharts.tickStep * focCharts.tickCount)
                max: focCharts.xAxisMaxValue
                tickCount: focCharts.tickCount
                gridLineColor: getGrayscaleColor(0.5)
                labelsColor: getGrayscaleColor(0.5)
            }

            ValuesAxis {
                id: yAxis
                min: focCharts.minVoltage
                max: focCharts.maxVoltage
                tickCount: focCharts.tickCount
                gridLineColor: getGrayscaleColor(0.5)
                labelsColor: getGrayscaleColor(0.5)
            }

            Text {
                text: "Time(ms)"
                color: getGrayscaleColor(0.5)
                font.pixelSize: 10
                anchors.bottom: parent.bottom
                anchors.horizontalCenter: parent.horizontalCenter
            }

            Text {
                text: "Voltage(V)"
                color: getGrayscaleColor(0.5)
                font.pixelSize: 10
                rotation: -90
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
            }

            Connections {
                target: SbotFoc
                function onFlushViewData(chartData) {
                    if(!stopData.isStop)
                    {
                        focCharts.appendData(rtAngleLine, chartData[0], chartData[1]);
                        angleData.rtAngleData = chartData[1].toFixed(2);  // 保留两位小数
                        focCharts.appendData(tarAngleLine, chartData[0], chartData[2]);
                        angleData.tarAngleData = chartData[2].toFixed(2);  // 保留两位小数
                        focCharts.appendData(alphaLine, chartData[0], chartData[3]);
                        abData.alphaData = chartData[3].toFixed(2);  // 保留两位小数
                        focCharts.appendData(betaLine, chartData[0], chartData[4]);
                        abData.betaData = chartData[4].toFixed(2);  // 保留两位小数
                        focCharts.appendData(aPhaseLine, chartData[0], chartData[5]);
                        phaseData.aPhaseData = chartData[5].toFixed(2);  // 保留两位小数
                        focCharts.appendData(bPhaseLine, chartData[0], chartData[6]);
                        phaseData.bPhaseData = chartData[6].toFixed(2);  // 保留两位小数
                        focCharts.appendData(cPhaseLine, chartData[0], chartData[7]);
                        phaseData.cPhaseData = chartData[7].toFixed(2);  // 保留两位小数
                        focCharts.xAxisMaxValue = chartData[0];
                    }
                }
            }
        }
    }
}
